<?php
/**
 * @Author: Marte
 * @Date:   2017-08-05 15:43:13
 * @Last Modified by:   Marte
 * @Last Modified time: 2017-08-12 21:36:04
 */
    header('Content-Type:text/html;charset=utf-8');
    $username=$_POST["username"];
    $password=$_POST["password"];
    // 接受填写的内容
    // 链接数据库
    include "../../include/confirm/connect_mysql.php";


    $sql="select * from userregisters where username='{$username}' and password='{$password}'";
    //查找数据库中用户名和密码都匹配的数据

    $result=$_mysql->query($sql);
    // print_r($result);
    //返回结果
    $_assoc=$result->fetch_assoc();//获取到检索出的那一行用户注册数据

    if($_assoc)
    {
         if($_assoc['status']==1)
        {
        // setCookie("username",$username,time()+3600*24);
        // setcookie("id",$_assoc['id'],time()+3600*24);
        // setCookie("status",$_assoc['status'],time()+3600*24);
        session_start();
         $_SESSION['username']=$username;//直接赋值

        //设置缓冲，24小时后过期
        //检索成功后，就自动跳转到首页，

        echo "<script>location='../../index.php?action=1'</script>";
        $_mysql->close();
        }else{
            echo "<script>alert('该账户未激活，请重新注册激活！');location='../../zc.php'</script>";
            $_mysql->close();
        }
    }
    else
    {
        //否者就继续登录
        echo "<script>location='../../dl.php?action=2'</script>";
        $_mysql->close();
    }







?>